import bpy
import ctypes
from bpy.types import Panel, Menu

from global_data.global_enum import *

import engine.initLIB.load_dll as engineLib
import ctypes


from engine.视口_渲染 import bl_预览视口




def f_update_开关预览窗口(self, context):
	bl_预览视口.g_是否绘制预览窗口 = context.scene.m_开启预览窗口
	engineLib.flexCAPI.f_开关预览窗口(ctypes.c_bool(bool(bl_预览视口.g_是否绘制预览窗口)))

class C_渲染面板Panel:
	bl_space_type = 'PROPERTIES'
	bl_region_type = 'WINDOW'
	bl_context = "render"

	@classmethod
	def poll(cls, context):
		print('context.engine = ', context.engine)
		return (context.engine == 'mbt_game_renderer')
		


class RENDER_PT_视口预览(C_渲染面板Panel, Panel):
	bl_label = "视口预览"
	#bl_options = {'DEFAULT_CLOSED'}
	COMPAT_ENGINES = {'mbt_game_renderer'}

	
	def draw(self, context):
		layout = self.layout
		
		scene = context.scene
		view = scene.view_settings

		layout.prop(scene, "m_开启预览窗口", icon='WORKSPACE')











classes = (
	#C_渲染面板Panel,
	RENDER_PT_视口预览,
)


def register():
	bpy.types.Scene.m_开启预览窗口 = bpy.props.BoolProperty(default=False, update=f_update_开关预览窗口)

	for c in classes:
		bpy.utils.register_class(c)
	bl_预览视口.register()


def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)
	bl_预览视口.unregister()



